//
//  NewsTableViewController.swift
//  SlidebarMenu
//
//  Created by Simon Ng on 24/10/2016.
//  Copyright © 2016 AppCoda. All rights reserved.
//

import UIKit

class NewsTableViewController: UITableViewController {
  
  @IBOutlet var menuButton:UIBarButtonItem!
  @IBOutlet weak var extraButton: UIBarButtonItem!
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    tableView.estimatedRowHeight = 242.0
    tableView.rowHeight = UITableViewAutomaticDimension
    
    addSideBarMenu(leftMenuButton: menuButton, rightMenuButton: extraButton)
  }
  
  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  // MARK: - Table view data source
  
  override func numberOfSections(in tableView: UITableView) -> Int {
    // Return the number of sections
    return 1
  }
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // Return the number of rows
    return 3
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NewsTableViewCell
    
    // Configure the cell...
    if indexPath.row == 0 {
      cell.postImageView.image = UIImage(named: "watchkit-intro")
      cell.postTitleLabel.text = "WatchKit Introduction: Building a Simple Guess Game"
      cell.authorLabel.text = "Simon Ng"
      cell.authorImageView.image = UIImage(named: "author")
      
    } else if indexPath.row == 1 {
      cell.postImageView.image = UIImage(named: "custom-segue-featured-1024")
      cell.postTitleLabel.text = "Building a Chat App in Swift Using Multipeer Connectivity Framework"
      cell.authorLabel.text = "Gabriel Theodoropoulos"
      cell.authorImageView.image = UIImage(named: "appcoda-fav-logo")
      
    } else {
      cell.postImageView.image = UIImage(named: "webkit-featured")
      cell.postTitleLabel.text = "A Beginner’s Guide to Animated Custom Segues in iOS 8"
      cell.authorLabel.text = "Gabriel Theodoropoulos"
      cell.authorImageView.image = UIImage(named: "appcoda-fav-logo")
      
    }
    
    return cell
  }
}


